function killport($p) {
    $conns = Get-NetTCPConnection -LocalPort $p -ErrorAction SilentlyContinue
    if ($conns) { 
        foreach ($c in $conns) { 
            $processId = $c.OwningProcess  # 使用 $processId 而不是 $pid
            Stop-Process -Id $processId -Force
            Write-Host "Killed port $p (PID: $processId)" -ForegroundColor Green 
        } 
    } else { 
        Write-Host "Port $p not occupied" -ForegroundColor Yellow 
    }
}